<template>
    <div class="house-wrapper">
        <div class="view">
            <div class="search-view">
                <div class="search">
                    <span>房源楼座：</span>
					<Select v-model="houseData.lou" placeholder="请选择" style="width: 150px;"> 
						<Option :value="0">A座</Option> 
						<Option :value="1">B座</Option> 
						<Option :value="2">C座</Option> 
					</Select>
                </div>
                <div class="search" style="margin-right: 0px;">
                    <span>房源面积：</span>
					<Input v-model="houseData.areaStart" placeholder="请输入房源面积" style="width: 150px;" />
                </div>
                <div class="search" style="margin-right: 0px;">--</div>
                <div class="search">
					<Input v-model="houseData.areaEnd" placeholder="请输入房源面积" style="width: 150px;" />
                </div>
                <div class="search">
                    <Button
                        type="primary"
                        :loading="isLoading"
                        @click="getHouseList">搜索
                    </Button>
                </div>
                 <div class="search fr">
                    <Button 
                        type="primary" 
                        @click="clickAdd">
                        添加房源
                    </Button>
                </div>
            </div>
            <div class="main-view">
                <HouseList 
                    :data="listData"
                    @on-action="clickAction">
                </HouseList>
            </div>
            <div class="page-view">
                <PageView
                    :data="pageData"
                    @on-change-page="changePage"
                    @on-change-pagesize="changePagesize">
                </PageView>
		    </div>
             <!-- 操作弹框 -->
            <div v-if="addData.isShow">
                <HouseModal
                    :data="addData"
                    @on-submit="submitAction">
                </HouseModal>
            </div>
        </div>
    </div>
</template>

<script>

import HouseList from '@/view/house/list/HouseList'
import PageView from '@/components/Page'
import HouseModal from '@/view/house/list/HouseModal'

export default {
    components: {
        HouseList,
        PageView,
        HouseModal
    },
    data () {
        return {
            isLoading: false,
            houseData: {
                lou: '',
                areaStart: '',
                areaEnd: ''
            },
            listData: {
                isLoading: false,
				data: [
                    {id: 1, lou: 0, num: '1101', chao: '南', mian: '1000平米', bao: '10万'},
                    {id: 2, lou: 0, num: '1101', chao: '南', mian: '1000平米', bao: '10万'},
                ]
            }, 
            pageData: {
				currentPage: 0,
				pagesize: 20,
				totalSize: 0
            },
            addData: {
				isLoading: false,
				actionType: null,
				isShow: false,
				row: null,
				data: {}
			},
        };
    },
    mounted(){
        // this.getHouseList()
    },
    methods: {
        changePage(page) {
            this.pageData.currentPage = page - 1;
            // this.getHouseList()
        },
        changePagesize(pagesize) {
            this.pageData.pagesize = pagesize;
            // this.getHouseList()
        },
        getHouseList(){

        },
        clickAdd(){
            this.addData.isShow = true
            this.addData.actionType = 1
            this.addData.data = {}
        },
        clickAction(type, formData) {
            console.log(type, formData)
            switch(type) {
                case 'edit': 
                    this.addData.isShow = true
                    this.addData.actionType = 2
                    this.addData.data = formData
                break;
                case 'del':
                    this.clickDel(formData);
                break;
            }
        },
        submitAction(formData) {
            // companyService.questionSave(formData.data).then(res=>{
            //     let result = res.data
            //     let code = result.rescode
            //     let resmsg = result.msg
            //     if(code == 100){
            //         this.$Message.success(resmsg)
            //         formData.isShow = false
            //         this.getHouseList()
            //     } else {
            //         this.$Message.error(resmsg)
            //     }
            // }, res=>{
            //     this.$Message.error('服务器异常，请稍后再使！')
            // })
        },
        clickDel(formData){
            // companyService.questionDel(formData.id).then(res=>{
            //     // console.log(formData.id)
            //     let result = res.data
            //     let code = result.rescode
            //     let resmsg = result.msg
            //     if(code == 100){
            //         this.$Message.success(resmsg)
            //         this.getProblemList()                    
            //     } else {
            //         this.$Message.error(resmsg)
            //     }
            // }, res => {
            //     this.$Message.error('服务器异常，请稍后再试！')
            // })
        }
    }
};
</script>

<style lang="less" scoped>
    .house-wrapper {
        padding: 40px 20px;
        .view {
            background: #fff;
            border: 1px solid #e6e6e6;
            padding: 30px 20px;
            .search-view {
                margin-bottom: 35px;
                .search {
                    margin-right: 40px;
                    display: inline-block;
                }
            }
        }
    }
</style>
